# -*- coding: utf-8 -*-
import sys
if sys.getdefaultencoding() != 'utf-8':
    reload(sys)
    sys.setdefaultencoding('utf-8')

ADDON_ID = 'plugin.program.dmdsplayer'

#import os, inspect
#cwd = os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0])
#sys.path[0:0] = [os.path.join(cwd, '../%s/resources/lib' % ADDON_ID)]
import xbmc
#xbmc.log(str(sys.path), 0)

def get_traceback():
    from cStringIO import StringIO
    h = StringIO()
    import traceback
    traceback.print_exc(file=h)
    return h.getvalue()

if __name__ == '__main__':
#    xbmc.executebuiltin('RunPlugin(plugin://plugin.program.dmdsplayer/run_on_startup)')
#    while not xbmc.abortRequested:
#        try:
#            if xbmc.getCondVisibility( "System.HasAddon(%s)" % ADDON_ID ):
#                from dmds.addon import startup_clear_lock
#                startup_clear_lock()
#                xbmc.executebuiltin('RunPlugin(plugin://plugin.program.dmdsplayer/run_on_startup)', wait=True)
#        except:
#            xbmc.log(get_traceback(), 3)
#        if xbmc.abortRequested:
#            break
#        break
#        xbmc.sleep(1000)
    xbmc.log('service.deamon.dmdsplayer exited.', 0)
